import React, { useEffect, useState } from 'react';
import { Modal, Form, Space } from 'antd';
import FormCondition from '@/components/FormCondition';
import { connect, history } from 'umi';
import aliOssUpload from '@/utils/aliOssUpload';
import { Button, Row, Col } from 'antd';
const CheckOrderForm = (props) => {
    const { visible = false, onClose, loading, dispatch, handleCallback, } = props;
    const { show = false, detail = {} } = visible;
    const { id, } = detail;
    const [status, setStatus] = useState(null)
    const [form] = Form.useForm();
    // 确认提交
    const handleUpAudit = () => {
        form.validateFields().then(async (values) => {
            const { images, text } = values
            const img = await aliOssUpload(images)
            dispatch({
                type: 'answering/fakeSaveHelpQaAnswer',
                payload: {
                    content: JSON.stringify({
                        images: img,
                        text
                    }),
                    userHelpQaId: id
                },
                callback: () => {
                    onClose()
                    handleCallback()

                }
            })

        });
    };
    useEffect(() => {

    }, [show])
    const formItems = [
        {
            label: `回复图片`,
            name: 'images',
            type: 'upload',
            maxFile: 9
        },
        {
            label: `回复`,
            name: 'text',
            type: 'textArea',
        },

    ];

    const modalProps = {
        title: '回复',
        width: 900,
        visible: show,
        maskClosable: true,
        destroyOnClose: true,
        zIndex: 1001,
        confirmLoading: loading,
    };

    return (
        <Modal {...modalProps} onCancel={onClose} onOk={handleUpAudit}>
            <FormCondition form={form} formItems={formItems}></FormCondition>
        </Modal >
    );
};

export default connect(({ order, loading }) => ({
    loading: loading.effects['answering/fakeSaveHelpQaAnswer'],
}))(CheckOrderForm);
;
